import { assertEquals } from "asserts";
import { runScript } from "leetcode-class";

import VendingMachine from "./index.ts";

Deno.test("VendingMachine", () => {
    assertEquals(
        [null, null, 10, -1, -1, -1],
        runScript(
            ["VendingMachine", "addItem", "sell", "sell", "sell", "sell"],
            [
                [],
                [0, 3, "Apple", 10, 10],
                [1, "Tom", "Apple", 1],
                [2, "Tom", "Apple", 3],
                [3, "Mary", "Banana", 2],
                [11, "Jim", "Apple", 1],
            ],
            VendingMachine,
        ),
    );
});
Deno.test("VendingMachine", () => {
    assertEquals(
        [null, null, null, 8, null, -1, 2, -1, null, 200, 196],
        runScript(
            [
                "VendingMachine",
                "addItem",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
            ],
            [
                [],
                [0, 1, "Apple", 4, 3],
                [1, 3, "Apple", 4, 2],
                [2, "Mary", "Apple", 2],
                [2, 1, "Banana", 2, 5],
                [4, "Jim", "Banana", 2],
                [4, "Mary", "Banana", 1],
                [4, "Mary", "Apple", 1],
                [6, 200, "Apple", 2, 5],
                [6, "Jim", "Apple", 100],
                [7, "Mary", "Apple", 100],
            ],
            VendingMachine,
        ),
    );
});
Deno.test("VendingMachine", () => {
    assertEquals(
        [
            null,
            null,
            null,
            174832,
            2650,
            39338,
            433,
            -1,
            null,
            15029,
            null,
            null,
            16773,
            673,
            null,
            4239,
            17913,
            -1,
            60885,
            -1,
            -1,
            null,
            -1,
            null,
            13930,
            null,
            -1,
            102683,
            -1,
            -1,
            -1,
            -1,
            -1,
            null,
            22480,
            23934,
            -1,
            -1,
            -1,
            null,
            -1,
            null,
            -1,
            -1,
            35759,
            -1,
            null,
            2210,
            1638,
            -1,
            -1,
            -1,
            -1,
            null,
            -1,
            -1,
            null,
            null,
            null,
            null,
            null,
            24817,
            8371,
            null,
            -1,
            856,
            2253,
            null,
            -1,
            7656,
            null,
            null,
            null,
            52255,
            null,
            -1,
            21783,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            -1,
            null,
            -1,
            -1,
            -1,
            null,
            -1,
            null,
            -1,
            -1,
            3493,
        ],
        runScript(
            [
                "VendingMachine",
                "addItem",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "addItem",
                "addItem",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "addItem",
                "addItem",
                "addItem",
                "addItem",
                "addItem",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "addItem",
                "addItem",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
                "addItem",
                "sell",
                "addItem",
                "sell",
                "sell",
                "sell",
            ],
            [
                [],
                [8, 358, "Sidedish", 116, 2],
                [13, 489, "Sidedish", 446, 213],
                [17, "Roxanne", "Sidedish", 392],
                [20, "Roxanne", "Sidedish", 6],
                [26, "Roxanne", "Sidedish", 90],
                [28, "Roxanne", "Sidedish", 1],
                [31, "Roxanne", "Sidedish", 1],
                [32, 172, "Sidedish", 101, 17],
                [34, "Roxanne", "Sidedish", 155],
                [35, 412, "Sidedish", 55, 14],
                [41, 427, "Sidedish", 354, 29],
                [45, "Roxanne", "Sidedish", 321],
                [47, "Roxanne", "Sidedish", 13],
                [52, 171, "Poaching", 106, 24],
                [59, "Roxanne", "Poaching", 43],
                [63, "Roxanne", "Sidedish", 55],
                [65, "Patrick", "Sidedish", 477],
                [67, "Roxanne", "Sidedish", 189],
                [71, "Roxanne", "Famine", 39],
                [72, "Garrett", "Sidedish", 1],
                [77, 410, "Atdinner", 469, 41],
                [79, "Garrett", "Sidedish", 1],
                [81, 234, "Sidedish", 446, 45],
                [83, "Roxanne", "Atdinner", 33],
                [91, 16, "Poaching", 20, 30],
                [101, "Megan", "Obesity", 337],
                [106, "Roxanne", "Atdinner", 246],
                [116, "Jeanette", "Poaching", 97],
                [120, "Roxanne", "Atdinner", 1],
                [122, "Roxanne", "Atdinner", 1],
                [133, "Roxanne", "Poaching", 1],
                [140, "Jo", "Poaching", 1],
                [141, 178, "Poaching", 393, 32],
                [144, "Roxanne", "Poaching", 65],
                [145, "Roxanne", "Poaching", 70],
                [161, "Roxanne", "Atdinner", 1],
                [165, "Megan", "Sidedish", 1],
                [167, "Roxanne", "Atdinner", 1],
                [173, 379, "Sidedish", 117, 22],
                [175, "Roxanne", "Poaching", 1],
                [182, 353, "Poaching", 385, 15],
                [184, "Patrick", "Atdinner", 1],
                [188, "Roxanne", "Sushi", 74],
                [192, "Roxanne", "Poaching", 108],
                [202, "Roxanne", "Sidedish", 1],
                [205, 35, "Baguette", 130, 8],
                [211, "Roxanne", "Baguette", 20],
                [213, "Roxanne", "Baguette", 15],
                [222, "Ulysses", "Baguette", 256],
                [229, "Melvin", "Baguette", 1],
                [232, "Leslie", "Atdinner", 351],
                [233, "Leslie", "Baguette", 1],
                [244, 371, "Poaching", 426, 7],
                [252, "Roxanne", "Poaching", 1],
                [254, "Roxanne", "Baguette", 1],
                [261, 479, "Sidedish", 260, 33],
                [267, 411, "Baguette", 474, 4],
                [268, 90, "Baguette", 462, 11],
                [279, 57, "Baguette", 352, 478],
                [280, 3, "Poaching", 199, 42],
                [281, "Roxanne", "Sidedish", 115],
                [282, "Roxanne", "Baguette", 29],
                [289, 225, "Sidedish", 255, 45],
                [291, "Roxanne", "Atdinner", 1],
                [300, "Roxanne", "Baguette", 3],
                [310, "Roxanne", "Baguette", 8],
                [313, 341, "Poaching", 101, 35],
                [321, "Garrett", "Sidedish", 337],
                [328, "Roxanne", "Sidedish", 38],
                [329, 191, "Feed", 31, 1],
                [330, 272, "Feed", 5, 52],
                [349, 246, "Poaching", 411, 31],
                [355, "Roxanne", "Poaching", 163],
                [361, 75, "Feed", 441, 16],
                [365, "Roxanne", "Obesity", 321],
                [367, "Patrick", "Poaching", 53],
                [368, "Jeanette", "Atdinner", 1],
                [370, "Roxanne", "Pottery", 429],
                [384, "Jo", "Feed", 261],
                [386, "Patrick", "Poaching", 1],
                [387, "Roxanne", "Sidedish", 1],
                [389, "Patrick", "Atdinner", 1],
                [390, "Leslie", "Atdinner", 438],
                [404, "Patrick", "Feed", 1],
                [425, "Patrick", "Atdinner", 1],
                [428, "Patrick", "Poaching", 1],
                [444, "Patrick", "Poaching", 1],
                [449, 143, "Baguette", 136, 13],
                [452, "Jeanette", "Poaching", 1],
                [454, "Patrick", "Feed", 1],
                [468, "Patrick", "Atdinner", 1],
                [469, 192, "Baguette", 126, 278],
                [470, "Patrick", "Atdinner", 1],
                [479, 202, "Feed", 2, 465],
                [483, "Roxanne", "Taco", 282],
                [488, "Patrick", "Atdinner", 1],
                [491, "Roxanne", "Baguette", 36],
            ],
            VendingMachine,
        ),
    );
});
